import { createApp } from "vue";
import App from "./App.vue";
import "./common/styles/index.scss";
import { setupStore } from "./store";
import { setupRouter, router } from "./router";
import { setupI18n } from "./lang";
import { setupGlobalComponents } from "./components/global.component";
import { setupRouterGuard } from "./router/guards";
import { setupGlobDirectives } from "./common/directives/index";

const bootstrap = async () => {
  const app = createApp(App);
  // store
  setupStore(app);
  // router
  setupRouter(app);
  // router guard
  setupRouterGuard(router);
  // i18n
  setupI18n(app);
  // global component
  setupGlobalComponents(app);
  // 注册全局指令
  setupGlobDirectives(app);

  // 当路由准备好时再执行挂载( https://next.router.vuejs.org/api/#isready)
  await router.isReady();
  app.mount("#app", true);
};

bootstrap();
